<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<!--#include file="lib/asp-json-lib.asp"-->
<%
Response.ContentType = "application/json"
action=saferequest("action",0)
username=saferequest("username",0)
password=saferequest("password",0)
'response.write(username)
'response.end
dim json
set json=jsObject()
if action="登录" then
	set rs=server.createobject("adodb.recordset")
	sql="select crm_empe.*,crm_permit.post,crm_permit.flag from crm_empe , crm_permit where  crm_empe.id=crm_permit.empe and crm_empe.username='"&username&"' and [password]='"&password&"' and active=1"
	' response.write sql
	' response.end
	rs.open sql,conn,1,1
	if not rs.eof then
		json("bStatus")=true
		session("sSystem")="edi"
		session("bLogin")=true
		session("iId")=rs("id")
		session("sUsername")=rs("username")
		session("sFullname")=rs("empe")
		session("iDept")=rs("dept")
		session("bCaptain")=rs("captain")
		session("aFields")=array("post","flag")
		'session("post")=rs("post")
		'session("flag")=rs("flag")
		'aaFlag=rs.getrows(,,session("aFields"))
		session("aaPostFlag")=rs.getrows(,,session("aFields"))
		session.TimeOut=60
		' set rs_post=server.createobject("adodb.recordset")
		' sql_post="select id,post from post order by id"
		' rs_post.open sql_post,conn,1,1
		' session("aaPost")=rs_post.getrows
		' rs_post.close
		' set rs_post=nothing
	else
		json("bStatus")=false
		json("sInfo")="登入错误"
	end if
	rs.close
	set rs=nothing
elseif action="退出" then
	session.abandon
	json("bStatus")=true
end if
json.Flush
%>
<!--#include file="lib/connclose.asp"-->